import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import { appConfig } from './src/config/index.js'

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    // 开发阶段启用源码映射：https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
    sourcemap: false,
  },
  plugins: [uni()],
  server: {
    open: true,
    proxy: {
      '/api': {
        target: appConfig.apiHost,
        changeOrigin: true,
        //rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        silenceDeprecations: ['legacy-js-api', 'color-functions'],
      },
    },
  },
})
